
#include "../../util/macros.h"
#include "../../matrix/matrix.h"

void image_threshold(Matrix * mGray, double th, double botton_val, double top_val, int inv) {
	long int i;
	double * mgray;
	long int size;
	
	_verify(mGray);

	size = mGray->size;
	mgray = mGray->data;

	for (i = 0; i < size; i++) {
		if(inv) mgray[i] = (mgray[i] <= th) ? top_val : botton_val;
		else mgray[i] = (mgray[i] <= th) ? botton_val : top_val;
	}
}


